package org.lfh.wintersun.utils;

import lombok.extern.slf4j.Slf4j;
import org.lfh.wintersun.web.user.entity.SysUserDetails;
import org.lfh.wintersun.web.user.entity.SysUserEntity;
import org.springframework.security.core.context.SecurityContextHolder;


@Slf4j
public class LoginUserHolder {

    public static Long getUserId() {
        return getCurrentUser().getId();
    }

    public static SysUserEntity getCurrentUser() {
        SysUserDetails sysUserDetails = (SysUserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        return sysUserDetails.getSysUserEntity();
    }

}
